import UIKit

enum ThemeColor {
    case background
    case text
    case separateLine
    
    func color(for style: UIUserInterfaceStyle) -> UIColor {
        switch self {
        case .background:
            return style == .dark ? UIColor(colorHex: 0x333333) : .white
        case .text:
            return style == .dark ? .white : UIColor(colorHex: 0x333333)
        case .separateLine:
            return style == .dark ? UIColor(colorHex: 0x252525) : .lightGray
        }
    }
}

class ThemeManager {
    static let shared = ThemeManager()
    
    private init() {}
    
    func dynamicColor(_ themeColor: ThemeColor) -> UIColor {
        if #available(iOS 13.0, *) {
            return UIColor { $0.userInterfaceStyle.themeColor(themeColor) }
        } else {
            return themeColor.color(for: .light)
        }
    }
}

private extension UIUserInterfaceStyle {
    func themeColor(_ color: ThemeColor) -> UIColor {
        color.color(for: self)
    }
}